home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / data-plo < prev    next >
Internet Message Format  |  1995-03-31  |  3KB

  1. From comp.sys.handhelds Thu Feb  7 11:03:00 1991
  2. Path: mentor.cc.purdue.edu!purdue!news.cs.indiana.edu!samsung!spool.mu.edu!sdd.hp.com!hplabs!hpfcso!rrd
  3. From: rrd@hpfcso.HP.COM (Ray Depew)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: Re: Plotting data point on HP48
  6. Message-ID: <7360065@hpfcso.HP.COM>
  7. Date: 5 Feb 91 17:51:46 GMT
  8. References: <4941@umbc3.UMBC.EDU>
  9. Organization: Hewlett-Packard, Fort Collins, CO, USA
  10. Lines: 65
  11.  
  12. Rouben Rostamian  asks:
  13.  
  14. >How does one plot the graph of a function given in a tabular form?
  15.  
  16. >Specifically, I have a program that generates a sequence of (x,y)
  17. >pairs and stores them in the stack.  The pairs represent points
  18. >on the graph of the solution of a differential equation.
  19. >Does anyone have a utility program for plotting a graph passing
  20. >through these points?  A simple linear interpolation between the points
  21. >will suffice.
  22.  
  23. Here's a quick program that will do what you want.  As with most
  24. connect-the- dots scatter plots, the data points are connected in the 
  25. same order they appear in your array.  This means that your output may
  26. be ugly and disordered, unless you sort your array first.
  27.  
  28. I'm reading this from my 48 display and typing it in here, so pleaswe]
  29. firgove typos.  You may be able to improve on this code, since I put
  30. it together in only a few minutes.
  31.  
  32. Regards
  33. Ray Depew
  34. HP ICBD -- IC's by Bill and Dave   
  35. rrd@hpfitst1.hp.com
  36.  
  37.  
  38. TREND
  39. -----
  40. Draws a SCATTER plot and connects the dots.
  41. Input:  Level 1:  A real array, or the name of a real array.
  42. Output:  Nothing on the stack.  (Draws the plot and displays it.)
  43. Caution:  Use [STAT] {XCOL} and [STAT] {YCOL} to choose your x- and
  44.           y-data columns correctly. 
  45. Checksum: #37143d
  46. Bytes:  253.5
  47.  
  48. Instructions:  Use TREND instead of SCATRPLOT -- that is, use it the same way
  49. you would use SCATRPLOT.  This means that you have to choose XCOL and YCOL 
  50. before you start.  If you want to "pretty up" your plot, you can use LABEL,
  51. AXES, DRAX and the other plotting functions to do so.
  52.  
  53. (In this listing, \GS is Sigma, or "Greek S".  Use [VARS] {\GSDAT}.     
  54.                   \-> is "right arrow".  Use [Rshift][0],
  55.                                           or [PRG]{OBJ}{\->LIST},
  56.                                           or [PRG]{OBJ}[NXT]{R\->C}.
  57.                   \=/ is "not equals".  Use [PRG]{TEST}[NXT]{\=/}.
  58. )
  59.  
  60. \<< SCATRPLOT                @ To set plot limits and draw axes.
  61.   IF DUP TYPE 3 \=/ THEN RCL END    @ Get the array on the stack.
  62.   DUP SIZE 1 GET            @ Array length (number of rows).
  63.   \GSPAR DUP 1 GET            @ x-data column no.
  64.   SWAP 2 GET                @ y-data column no.
  65.   \-> arry n xcol ycol
  66.   \<< 1 n 1 - FOR j            @ Number of line segments to draw.
  67.         arry DUP j xcol 2 \->LIST GET 
  68.         OVER j ycol 2 \->LIST GET R\->C        @ First endpoint.
  69.         OVER j 1 + xcol 2 \->LIST GET
  70.         3 PICK j 1 + ycol 2 \->LIST GET R\->C    @ The other endpoint.
  71.         LINE                @ Draw the line.
  72.       NEXT
  73.       { } PVIEW                @ Keep it in the display for as long
  74.   \>>                    @   as you want it.
  75. \>>
  76.     
  77.  
  78.